<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java并发编程工具包 - JUC深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #4f46e5;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 代码块美化 */
        pre {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            position: relative;
            margin: 2rem 0;
        }
        
        pre::before {
            content: attr(data-language);
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            font-size: 0.75rem;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }
        
        /* 卡片悬停效果 */
        .feature-card {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        .feature-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }
        
        /* 标题装饰线 */
        .section-title::after {
            content: '';
            display: block;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 100%);
            margin-top: 1rem;
            border-radius: 2px;
        }
        
        /* 引用样式 */
        .custom-quote {
            border-left: 4px solid #4f46e5;
            background: rgba(79, 70, 229, 0.05);
            padding: 1.5rem 2rem;
            margin: 2rem 0;
            border-radius: 0 8px 8px 0;
            position: relative;
        }
        
        .custom-quote::before {
            content: '\f10d';
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            position: absolute;
            top: -10px;
            left: 20px;
            font-size: 2rem;
            color: #4f46e5;
            opacity: 0.2;
        }
        
        /* 时间线样式 */
        .timeline-item {
            position: relative;
            padding-left: 3rem;
            margin-bottom: 2rem;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0.5rem;
            width: 1rem;
            height: 1rem;
            background: #4f46e5;
            border-radius: 50%;
            box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
        }
        
        .timeline-item::after {
            content: '';
            position: absolute;
            left: 0.5rem;
            top: 1.5rem;
            width: 1px;
            height: calc(100% + 1rem);
            background: #e5e7eb;
        }
        
        .timeline-item:last-child::after {
            display: none;
        }
        
        /* 代码高亮 */
        code {
            background: rgba(79, 70, 229, 0.1);
            padding: 0.2rem 0.4rem;
            border-radius: 4px;
            font-size: 0.9em;
            color: #4f46e5;
        }
        
        /* 滚动动画 */
        .fade-in {
            opacity: 0;
            transform: translateY(20px);
            animation: fadeIn 0.8s ease-out forwards;
        }
        
        @keyframes fadeIn {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* Mermaid图表样式 */
        .mermaid {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="relative overflow-hidden bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 text-white">
        <div class="absolute inset-0 bg-black opacity-20"></div>
        <div class="relative container mx-auto px-6 py-24">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-7xl font-bold mb-6 tracking-tight">
                    Java并发编程工具包
                </h1>
                <p class="text-2xl md:text-3xl mb-8 opacity-90">JUC深度解析与实战指南</p>
                <div class="flex justify-center space-x-8 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-code mr-2"></i>
                        <span>高性能并发</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-rocket mr-2"></i>
                        <span>异步编程</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-shield-alt mr-2"></i>
                        <span>线程安全</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0">
            <svg viewBox="0 0 1440 120" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M0 120L60 105C120 90 240 60 360 45C480 30 600 30 720 37.5C840 45 960 60 1080 67.5C1200 75 1320 75 1380 75L1440 75V120H1380C1320 120 1200 120 1080 120C960 120 840 120 720 120C600 120 480 120 360 120C240 120 120 120 60 120H0Z" fill="white"/>
            </svg>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12 max-w-6xl">
        
        <!-- JUC介绍 -->
        <section class="mb-16 fade-in">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-4xl font-bold text-gray-800 mb-6 section-title">什么是JUC</h2>
                <p class="text-lg text-gray-700 leading-relaxed drop-cap">
                    JUC的意思是java并发编程工具包，是java.util.concurrent包的简称。目的就是为了更好的支持高并发任务，让开发者利用这个包进行的多线程开发时，可以有效的减少竞争条件和死锁线程。在现代应用开发中，JUC已经成为处理并发问题的核心工具集。
                </p>
            </div>
        </section>

        <!-- 核心概念可视化 -->
        <section class="mb-16 fade-in">
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <h3 class="text-2xl font-bold text-gray-800 mb-6">JUC核心组件关系图</h3>
                <div class="mermaid">
                    graph TB
                        A[JUC并发工具包] --> B[异步编程]
                        A --> C[定时调度]
                        A --> D[请求合并]
                        A --> E[Fork/Join框架]
                        
                        B --> B1[CompletableFuture]
                        B --> B2[异步回调]
                        B --> B3[任务串行化]
                        B --> B4[任务组合]
                        
                        C --> C1[ScheduledExecutorService]
                        C --> C2[@Scheduled注解]
                        C --> C3[Cron表达式]
                        
                        D --> D1[批量接口优化]
                        D --> D2[请求队列]
                        D --> D3[定时批处理]
                        
                        E --> E1[任务分割]
                        E --> E2[工作窃取]
                        E --> E3[并行计算]
                        
                        style A fill:#4f46e5,stroke:#333,stroke-width:3px,color:#fff
                        style B fill:#7c3aed,stroke:#333,stroke-width:2px,color:#fff
                        style C fill:#7c3aed,stroke:#333,stroke-width:2px,color:#fff
                        style D fill:#7c3aed,stroke:#333,stroke-width:2px,color:#fff
                        style E fill:#7c3aed,stroke:#333,stroke-width:2px,color:#fff
                </div>
            </div>
        </section>

        <!-- 异步编程 -->
        <section class="mb-16 fade-in">
            <div class="bg-gradient-to-r from-purple-50 to-indigo-50 rounded-2xl p-8 md:p-12">
                <h2 class="text-4xl font-bold text-gray-800 mb-8 section-title">异步编程</h2>
                
                <div class="bg-white rounded-xl p-6 mb-8 shadow-lg">
                    <h3 class="text-2xl font-semibold text-gray-800 mb-4">
                        <i class="fas fa-shopping-cart text-purple-600 mr-3"></i>
                        用户下单场景分析
                    </h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="space-y-4">
                            <div class="timeline-item">
                                <h4 class="font-semibold text-gray-700">1. 查询地址信息</h4>
                                <p class="text-gray-600">耗时：0.5秒</p>
                            </div>
                            <div class="timeline-item">
                                <h4 class="font-semibold text-gray-700">2. 查询购物车数据</h4>
                                <p class="text-gray-600">耗时：0.5秒</p>
                            </div>
                            <div class="timeline-item">
                                <h4 class="font-semibold text-gray-700">3. 查询商品信息</h4>
                                <p class="text-gray-600">耗时：1秒</p>
                            </div>
                        </div>
                        <div class="space-y-4">
                            <div class="timeline-item">
                                <h4 class="font-semibold text-gray-700">4. 创建订单</h4>
                                <p class="text-gray-600">耗时：0.5秒</p>
                            </div>
                            <div class="timeline-item">
                                <h4 class="font-semibold text-gray-700">5. 创建订单详情</h4>
                                <p class="text-gray-600">耗时：0.5秒</p>
                            </div>
                            <div class="timeline-item">
                                <h4 class="font-semibold text-gray-700">6. 扣减库存</h4>
                                <p class="text-gray-600">耗时：待定</p>
                            </div>
                        </div>
                    </div>
                    <div class="mt-6 p-4 bg-red-50 rounded-lg">
                        <p class="text-lg font-semibold text-red-800">
                            <i class="fas fa-exclamation-triangle mr-2"></i>
                            同步执行总耗时：3秒+
                        </p>
                    </div>
                </div>

                <div class="custom-quote">
                    <p class="text-lg text-gray-700">
                        用户创建一个订单总共耗时3秒，每个操作都是同步执行的。如果变成异步是否会提高性能？答案是肯定的！通过CompletableFuture，我们可以将这些独立的操作并行执行，大幅缩短总体耗时。
                    </p>
                </div>
            </div>
        </section>

        <!-- CompletableFuture详解 -->
        <section class="mb-16 fade-in">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-4xl font-bold text-gray-800 mb-8 section-title">CompletableFuture</h2>
                <p class="text-lg text-gray-700 mb-8">
                    Java8新增了CompletableFuture，提供对异步计算的支持，可以通过回调的方式